function main(defaultParams, event) {
    console.log(defaultParams);
    const self = this;
    debugger

    let queryParams = [{
        "name": "pageId",
        "valueContent": "0060d7c2-2b94-40d4-b5ed-e36bb4f1d0b9"
    }];

    const cardIds = defaultParams.cardId.value;

    self.$lc_Confirm({
        content: "确定对选中的人员发起资格申请提交？",
        type: "info",  // danger info warning
        headerTitle: "提示", //确认框头部标题 提示、警告、告警
        showOkBtn: true, // 是否展示确认按钮
        showCancelBtn: true, // 是否展示取消按钮
        cancelText: "取消", //取消按钮 展示文字
        okText: "确定",  //确认按钮 展示文字
        onOk: () => {
            debugger
            // 提交证件批量提交
            saveCardIds({ cardIds, type: 2 }).then(res => {
                if (res.result) {
                    let applyId = res.result + '';
                    let jsonParams = {
                        documentNo:applyId
                    };
                    api.DATA_SOURCE_EXECUTE("ds_api:d4fd4546-c043-4a9e-80d9-5e1cc16fa441", "api", queryParams, [], JSON.stringify(jsonParams)).then((res) => {
                        console.log("响应", res);
                        if (!res.hasError) {
                            // 修改证件的状态为待审核 1
                            updateLawCardInfo(cardIds)
                            // 修改当前批次的状态为 1
                            updateLawCardApplyBattchInfo(applyId)
                            jumpToPage(self, res.result.content || res.result, defaultParams);
                        } else {
                            self.$message.error(res.message);
                        }
                    }).catch(err => {
                        self.$message.error(err.message);
                    });
                } else {
                    self.$message.warning("保存失败");
                    resolve(false);
                }
            })


        }
    })
}


/**
 * 修改证件的审核状态
 * 状态变化为 0 - 1
 */
function updateLawCardInfo(cardIds) {
    // params中为api接口的query参数
    let params = [{
        name: "ids", valueContent: cardIds
    }, {
        name: "tableId", valueContent: "ds_tbl:t_7ce84a1bbcd14ae08f12a2c7e55bf626"
    }];
    let columnData = {
        "columnDataList": [{
            "columnId": "f_9c445c725c734e2cb05382baa785eca6", "value": "已提交"
        }, {
            "columnId": "f_7f40dbbff48948d0a677997f90ddef47", "value": "1"
        }]
    }
    api.DATA_SOURCE_EXECUTE("ds_api:da5b0753-e7f0-46c9-b9d8-f00f22558e53", "api", params, [], JSON.stringify(columnData)).then((res) => {
        // then() 为调用成功的回调
        console.log(res)
    }).catch(err => {
        self.$message.error(err.message); // 显示错误提示信息
    });
}


/**
 * 在进行审核之后
 * law_card_apply_batch_info
 * 修改流程的状态 由0 - 1
 * valid_flag = 1
 */
function updateLawCardApplyBattchInfo(documentNo) {
    api.EXEC_FORMULA("UPDATE('ds_tbl:t_6eda087f8b7e4a3aa5b3e39b81df4aa1', QUERY_EQ('documentNo', '" + documentNo + "'), '', ['state', '" + 1 + "','valid_flag', '" + 1 + "'])").then(res => {
        console.log('Update result:', res);
    });
}


/**
 * 保存选中的 cardIds
 * @param {Object} params - 包含 cardIds (string) 和 type (number)
 * @returns {Promise<Object>}
 */
function saveCardIds(params) {
    return new Promise((resolve, reject) => {
        api.DATA_SOURCE_EXECUTE(
            "ds_api:8ed92ede-82a0-4b4c-be3a-20f38006e2f5",
            "api", [], [], JSON.stringify(params)
        ).then(res => {
            resolve(JSON.parse(res.result));
        }).catch(reject);
    });
}

/**
 * 跳转到流程批转页面
 * @param self
 * @param result
 * @param defaultParams
 */
function jumpToPage(self, result, defaultParams) {
    var element = self;
    var rootPageElement = null;
    result = JSON.parse(result);

    while (element) {
        if (element.getPageInfo && element.goHistory) {
            rootPageElement = element;
            break;
        } else {
            element = element.$parent;
        }
    }
    if (rootPageElement) {
        debugger
        var data = result.result;
        data.detail = 1;
        data.boxType = 1;
        // 更新页面数据
        // rootPageElement.getPageInfo("1932314802592960512");
        rootPageElement.getPageInfo("1873648101448638464-bc7a");
        // 设置其他参数
        rootPageElement.extraParams_ = data;
    }
    setTimeout(() => {
        console.log(rootPageElement);
    }, 2000)
}
